package com.hungryinlindholmen;

import java.sql.Date;
import java.util.Calendar;

/**
 * Creates an array of 7 strings with dates for each day of the coming week. The
 * strings are used in the advanced search box of the restaurant application and
 * eventually used to make search-queries.
 * 
 * @author Olof Ekelund
 */

public class GetTimeStrings {
    public GetTimeStrings() {

    }

    public String[] getArray() {
	String[] time = new String[7];

	Calendar cal = Calendar.getInstance();
	java.util.Date utilDate = cal.getTime();
	java.sql.Date today = new Date(utilDate.getTime());

	cal.setTime(today);
	cal.set(Calendar.HOUR_OF_DAY, 0);
	cal.set(Calendar.MINUTE, 0);
	cal.set(Calendar.SECOND, 0);
	cal.set(Calendar.MILLISECOND, 0);

	today = new java.sql.Date(cal.getTimeInMillis());

	for (int i = 0; i < 7; i++) {
	    today = new java.sql.Date(cal.getTimeInMillis());
	    cal.add(Calendar.DAY_OF_YEAR, 1);
	    time[i] = today.toString();
	}

	return time;
    }
}
